import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/login/Login.vue'
import Layout from '@/views/layout/Layout.vue'
import Home from '@/views/home/Home.vue'
import Question from '@/views/question/Question.vue'
import Video from '@/views/video/Video.vue'
import Uesr from '@/views/uesr/Uesr.vue'
import Search from '@/views/search/Search.vue'
import Article from '@/views/article/Article.vue'
import UesrProfile from '@/views/uesrProfile/UesrProfile.vue'
import Websocket from '@/views/websocket/Websocket.vue'

Vue.use(Login)
Vue.use(Layout)
Vue.use(Home)
Vue.use(Question)
Vue.use(Video)
Vue.use(Uesr)
Vue.use(Article)
Vue.use(UesrProfile)
Vue.use(Websocket)
Vue.use(VueRouter)

// 路由表
const routes = [
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/search',
    name: 'search',
    component: Search
  },
  {
    path: '/',
    // name: 'layout',
    component: Layout,
    children: [
      {
        path: '',
        name: 'home',
        component: Home
      },
      {
        path: '/question',
        name: 'Question',
        component: Question
      },
      {
        path: '/video',
        name: 'video',
        component: Video
      },
      {
        path: '/uesr',
        name: 'uesr',
        component: Uesr
      }
    ]
  },
  {
    path: '/article/:articleId',
    name: 'article',
    component: Article,
    props: true // 开启 props传参，把路由参数映射到
  },
  {
    path: '/uesrProfile',
    name: 'UesrProfile',
    component: UesrProfile
  },
  {
    path: '/websocket',
    name: 'Websocket',
    component: Websocket
  }
]

const router = new VueRouter({
  routes
})

export default router
